/** * NFIS Mortgage Theme * * @package nfis-theme * @author NFIS Mortgage Brokers * @license GPL-2.0-or-later * @version 1.0.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } if ( ! defined( 'NFIS_THEME_VERSION' ) ) { define( 'NFIS_THEME_VERSION', '1.0.0' ); } if ( ! defined( 'NFIS_THEME_DIR' ) ) { define( 'NFIS_THEME_DIR', get_template_directory() ); } if ( ! defined( 'NFIS_THEME_URI' ) ) { define( 'NFIS_THEME_URI', get_template_directory_uri() ); } /** * Theme setup. */ if ( ! function_exists( 'nfis_theme_setup' ) ) : function nfis_theme_setup() { load_theme_textdomain( 'nfis-mortgage', NFIS_THEME_DIR . '/languages' ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'title-tag' ); add_theme_support( 'post-thumbnails' ); add_theme_support( 'custom-logo', array( 'height' => 60, 'width' => 200, 'flex-height' => true, 'flex-width' => true, ) ); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'script', 'style', ) ); add_theme_support( 'wp-block-styles' ); add_theme_support( 'responsive-embeds' ); add_theme_support( 'align-wide' ); add_theme_support( 'editor-styles' ); add_editor_style( 'assets/css/editor-style.css' ); register_nav_menus( array( 'primary' => __( 'Primary Menu', 'nfis-mortgage' ), 'footer' => __( 'Footer Menu', 'nfis-mortgage' ), 'mobile' => __( 'Mobile Menu', 'nfis-mortgage' ), ) ); // Image sizes. add_image_size( 'nfis-featured', 1200, 630, true ); add_image_size( 'nfis-blog-thumb', 400, 260, true ); add_image_size( 'nfis-team', 400, 400, true ); } add_action( 'after_setup_theme', 'nfis_theme_setup' ); endif; /** * Enqueue scripts and styles. */ if ( ! function_exists( 'nfis_theme_scripts' ) ) : function nfis_theme_scripts() { // Google Fonts. $fonts_url = add_query_arg( array( 'family' => urlencode( 'Spectral:ital,wght@0,500;0,600;0,700;1,500;1,600&Source+Sans+3:wght@400;500;600;700' ), 'display' => 'swap', ), 'https://fonts.googleapis.com/css' ); wp_enqueue_style( 'nfis-fonts', esc_url( $fonts_url ), array(), NFIS_THEME_VERSION ); wp_style_add_data( 'nfis-fonts', 'rtl', 'replace' ); // Main stylesheet. wp_enqueue_style( 'nfis-style', get_stylesheet_uri(), array(), NFIS_THEME_VERSION ); // Theme JavaScript. wp_enqueue_script( 'nfis-main', NFIS_THEME_URI . '/assets/js/main.js', array(), NFIS_THEME_VERSION, true ); wp_script_add_data( 'nfis-main', 'async', true ); // FAQ JavaScript (only on pages with FAQ). if ( is_page() ) { global $post; $post_content = $post ? $post->post_content : ''; if ( strpos( $post_content, 'faq__item' ) !== false || has_block( 'nfis-mortgage/faq-accordion', $post ) ) { wp_enqueue_script( 'nfis-faq', NFIS_THEME_URI . '/assets/js/faq.js', array(), NFIS_THEME_VERSION, true ); } } // Comment reply script. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'nfis_theme_scripts' ); endif; /** * Register widget areas. */ if ( ! function_exists( 'nfis_theme_widgets_init' ) ) : function nfis_theme_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar', 'nfis-mortgage' ), 'id' => 'sidebar-1', 'description' => __( 'Add widgets here to appear in your sidebar.', 'nfis-mortgage' ), 'before_widget' => '', 'before_title' => '